import $http  from "@/utils/http";
import $toast from '@/utils/toast';

/**
 * 预购商品详情
 * @param  {[type]} goods_id 商品id
 * @param  string   status //即将上线 1  新品体验2
 * @return Promise
 */
export function getYGDetail({ goods_id, uid } = {})
{
	return $http.post('',{ module : 'Goods#yg_goodsDetail', goods_id, uid });
}

/**
 * 体验商品详情
 * @param  {[type]} goods_id 商品id
 * @param  string   status //即将上线 1  新品体验2
 * @return Promise
 */
export function getTYDetail({ goods_id, status, b_state, uid })
{
	return $http.post('',{ module : 'Goods#goodsDetail', goods_id, status, b_state, uid  });
}

/**
 * 在售商品详情
 * @param  {[type]} goods_id 商品id
 * @return Promise
 */
export function getXPDetail(goods_id)
{
	return $http.post('',{ module : 'Goods#sales_goodsDetail', goods_id});
}
/**
 * 活动列表页
 * @param  {[type]} type 导航 nav_url
 * @return Promise
 */
export function getActivityList({ uid,type, page_index, page_size })
{
	return $http.post('',{ module : 'Activity#activitylist',uid, type, page_index, page_size });
}

/**
 * 活动详情页
 * @param  {[uid]} uid 用户uid 
 * @param  {[goods_id]} goods_id 商品id 
 * @return Promise
 */
export function getActivityDetail( { goods_id, uid })
{
	return $http.post('',{ module : 'Activity#activitydetail', goods_id, uid });
}

/**
 * 我的助力，我的抽奖 
 * @param  {[uid]} uid 用户uid 
 * @param  {[goods_id]} goods_id 商品id 
 * @parm   {[activity_cate]} activity_cate 活动类型 1：幸运助力 2：免费抽奖 3：分享有礼
 * @param  {[page_index]} page_index    页数
 * @param  {[page_size]} page_size     条数
 * @return Promise
 */
export function getMyHelp({uid, goods_id, activity_cate, page_index, page_size})
{
	return $http.post('',{module : 'Activity#my_help', uid, goods_id, activity_cate, page_index, page_size});
}

/**
 * 免费抽奖按钮
 * @param  {[type]} uid      用户uid 
 * @param  {[type]} goods_id 商品id 
 * @return {[type]}               
 */
export function getFreeLottery({uid, goods_id, address_id})
{
	return $http.post('',{module : 'Activity#free_lottery', uid, goods_id, address_id});
}
/**
 * 判断免费抽奖按钮的状态
 * @param  {[type]} uid      用户uid 
 * @param  {[type]} goods_id 商品id 
 * @return {[type]}               
 */
export function getFreeLotteryStatus({uid, goods_id,})
{
	return $http.post('',{module : 'Activity#free_lottery_status', uid, goods_id});
}
/**
 * 我的助力查看详情
 * @param  {[uid]} uid 用户uid
 * @param  {[goods_id]} goods_id 商品id 
 * @parm {[activity_cate]} activity_cate 活动类型 1：幸运助力 2：免费抽奖 3：分享有礼
 * @return Promise
 */
export function getActivityDetatil( {uid, goods_id , activity_cate })
{
	return $http.post('',{module : 'Activity#activity_detatil', uid, goods_id , activity_cate});
}

/**
 * 幸运助力详情页
 * @param  {[uid]} uid 用户uid 
 * @param  {[goods_id]} goods_id 商品id 
 * @param  {[address_id]} address_id 地址id 
 * @return Promise
 */
export function getHelp( {goods_id , address_id, uid })
{
	return $http.post('',{module : 'Activity#get_help', goods_id, address_id, uid,});
}

/**
 * 幸运助力参与助力人
 * @param  {[uid]} uid 用户uid 
 * @param  {[goods_id]} goods_id 商品id 
 * @param  {[address_id]} address_id 地址id 
 * @param  {[page_index]} page_index    页数
 * @param  {[page_size]} page_size     条数
 * @return Promise
 */
export function getHelpPeople( { goods_id, uid, page_index, page_size })
{
	return $http.post('',{module : 'Activity#get_help_people', goods_id, uid, page_index, page_size});
}

/**
 * 帮助好友幸运助力
 * @param  {[uid]} uid 用户uid 
 * @param  {[goods_id]} goods_id 商品id
 * @param  {[fuid]} fuid 一级用户id
 * @return Promise
 */
export function getHelpShare({ uid, fuid, goods_id })
{
	return $http.post('',{module : 'Activity#help_button', uid, fuid, goods_id});
}

/**
 * 微信分享幸运助力
 * @param  {[goods_id]} goods_id 商品id
 * @param  {[fuid]} fuid 一级用户id
 * @return Promise
 */
export function getWechatShare({ fuid, goods_id }) 
{ 
	return $http.post('',{module : 'Activity#share_content', fuid,goods_id });
}

/**
 * 获取微信config配置
 * @return Promise
 */
export function getWechatConfig(url)
{
	// return $http.get('', { module : 'Activity#wechatConfig', url : url });
	return $http.post('',{ module : 'Activity#wechatConfig', url });
}

/**
 * 免费抽奖分享成功后事件
 * @param  {[goods_id]} goods_id 商品id
 * @param  {[fuid]} fuid 一级用户id
 * @return Promise
 */
export function getFreeLotteryShare({ goods_id, fuid, uid })
{ 
	return $http.post('',{module : 'Activity#free_lottery_share', goods_id, fuid, uid});
}

/**
 * 微信分享免费抽奖
 * @param  {[goods_id]} goods_id 商品id
 * @param  {[fuid]} fuid 一级用户id
 * @return Promise
 */
export function getLotteryWxshare({ goods_id, fuid })
{ 
	return $http.post('',{module : 'Activity#lottery_wxshare', goods_id, fuid});
}

/**
 * 分享有礼--分享
 * @param  {[goods_id]} goods_id 商品id
 * @param  {[uid]}  uid  用户uid
 * @param  {[type]} type 类型 3：分享有礼
 * @param  {[page]} page 页数
 * @param  {[item]} item 条数
 * @return Promise
 */
export function getFriendShareList({ uid, goods_id, type, page, item })
{
	return $http.post('',{module : 'Presenttoshare#friendToShareList', uid, goods_id, type, page, item});
}

/**
 * 分享有礼--分享详情
 * @param  {[goods_id]} goods_id 商品id
 * @param  {[uid]} uid 用户id
 * @param  {[address_id]} address_id 地址id
 * @return Promise
 */
export function getShareIndex({ uid, goods_id, address_id })
{
	return $http.post('',{module : 'Presenttoshare#index', uid, goods_id, address_id});
}

/**
 * 分享有礼--我的分享
 * @param  {[goods_id]} goods_id 商品id
 * @param  {[fuid]} fuid 一级用户id
 * @return Promise
 */
export function getMyShare({ uid, page, item })
{
	return $http.post('',{module : 'Presenttoshare#myShare', uid, page, item });
}

/**
 * 分享有礼--好友列表
 * @param  {[type]} options.uid  用户id
 * @param  {[type]} options.page 页数
 * @param  {[type]} options.item 条数
 * @return {[type]}              [description]
 */
export function getFriend({type, uid, goods_id })
{
	return $http.post('',{module:'Presenttoshare#noPageToMyShare', type, uid, goods_id })
}


/**
 * 分享有礼--获取分享标题、链接、内容
 * @param  {[goods_id]} goods_id 商品id
 * @param  {[uid]} uid 用户id
 * @param  {[type]} type 活动类型 分享有礼：3
 * @return Promise
 */
export function getShareLink({ uid, goods_id, type })
{
	return $http.post('',{module : 'Presenttoshare#rewardShareLink', uid, goods_id, type});
}

/**
 * 分享有礼--微信分享有礼
 * @param  {[goods_id]} goods_id 商品id
 * @param  {[uid]} uid 用户id
 * @param  {[parent_id]} parent_id 父级用户id
 * @param  {[type]} type 活动类型 分享有礼：3
 * @return Promise
 */
export function getClickHelpShare( { uid, parent_id, goods_id, type})
{
	return $http.post('',{module : 'Presenttoshare#userClickCollectLuckScore', uid, parent_id, goods_id, type});
}


/**
 * 拼团分享
 * @param  {[type]} options.type     1 拼单分享
 * @param  {[type]} options.goods_id 商品id
 * @param  {[type]} options.uid      父分类的用户id
 * @return Promise
 */
export function getgroupShare({ type, goods_id, uid })
{
	return $http.post('',{module : 'Activity#wxshareContent', type, goods_id, uid });
}

/**
 * 微信授权
 * @param  {[goods_id]} goods_id 商品id
 * @param  {[uid]} uid 用户id
 * @param  {[fuid]} fuid 父级用户id
 * @param  {[type]} type 活动类型 分享有礼：3
 * @return Promise
 */
export function getWchatPublicLogin({  fuid, goods_id, type })
{
	return $http.post('',{module : 'Thirdlogin#wchatPublicLogin', fuid, goods_id, type});
}

/**
 * 详情页 评论
 * @param  {[type]} goods_id 商品ID
 * @return Promise
 */
export function getCommentsCount( goods_id )
{	
	return $http.post('',{ module : 'Goods#getCommentsCount', goods_id });
}

/**
 * 商品评论
 * @param  {[type]} options.comments_type 0:全部1好评2中评3差评4图片
 * @param  {[type]} options.goods_id      商品id
 * @param  {[type]} options.page_index    页数
 * @param  {[type]} options.page_size     条数
 * @return Promise
 */
export function getGoodsComments({ comments_type, goods_id, page_index, page_size })
{
	return $http.post('',{ module : 'Goods#getGoodsComments',comments_type, goods_id, page_index, page_size });
}


export function getLuckyList(sku_id)
{
	return $http.post('',{ module : 'Goods#luckNameList',sku_id });
}


/**
 * 体验页面详情页--确定预约处理
 * @param  {[type]} sku_id 		商品ID
 * @param  {[type]} uid 		用户ID
 * @param  {[type]} shop_id 	商品ID
 * @param  {[type]} address_id  地址ID
 * @param  {[type]} sign  		是否使用体验券 0 默认系统免费赠送 1 使用体验券
 * @return Promise
 */
export function userYuyuehandler({sku_id, uid, shop_id, address_id, sign})
{	
	return $http.post('',{ module : 'Goods#userYuyuehandler', sku_id, uid, shop_id, address_id, sign });
}



export function beAboutTo({ type, page_index, page_size })
{
	return $http.post('',{ module : 'Home#come_goods',type, page_index, page_size })
}


/**
 * 拼图详情参与列表
 * @param  {[type]} options.goods_id   商品id
 * @param  {[type]} options.page_index 页数
 * @param  {[type]} options.page_size  数量
 * @return Promise
 */
export function joinList({ uid, goods_id, page_index, page_size })
{
	return $http.post('',{ module : 'Goods#joinlist',uid, goods_id, page_index, page_size })
}


/**
 * 立即分享按钮
 * @param  {[type]} goods_id 商品id
 * @return Promise
 */
export function share({ goods_id,fuid,order_id })
{
	return $http.post('',{ module : 'Goods#yg_share', goods_id, fuid ,order_id})
}



/**
 * 投诉商品
 * @param  {[type]} options.goods_id            商品id
 * @param  {[type]} options.uid                 用户id
 * @param  {[type]} options.platform            平台名称
 * @param  {[type]} options.platform_goods_name 平台上商品名称
 * @param  {[type]} options.link                链接
 * @param  {[type]} options.images              图片字符串 多个 | 分隔
 * @return Promise
 */
export function commitComplain ({ goods_id, uid, platform, platform_goods_name, link, images }) 
{

	if(!platform)
		return new Promise (() =>{ $toast('请输入平台名称') });

	if(!platform_goods_name)
		return new Promise (() =>{ $toast('请输入平台商品名称') });

	return $http.post('',{ module : 'Goods#complain_submit', goods_id, uid, platform, platform_goods_name, link, images });
}


/**
 * 微信二维码分享
 * @param  {[type]} options.fuid     父类uid
 * @param  {[type]} options.uid      uid
 * @param  {[type]} options.goods_id 商品id
 * @param  {[type]} options.type     分享类型 1：幸运助力 2：免费抽奖 3：分享有礼

 * @return Promise
 */
export function wechatCode({ fuid, uid, goods_id,type })
{
	return $http.post('',{ module: 'Activity#wechatqrcode',fuid, uid, goods_id,type });
}


/**
 * 拼团详情
 * @param  {[type]} options.order_id 订单id
 * @param  {[type]} options.goods_id 商品id
 * @param  {[type]} options.fuid     父分类用户id
 * @return Promise
 */
export function getGroupBooking({ order_id, goods_id, fuid })
{
	return $http.post('',{module:'Activity#pingShareDetail',order_id, goods_id,fuid })
}

/**
 * 拼团分享寻找伙伴
 * @param  {[type]} options.page_index 页数
 * @param  {[type]} options.page_size  数量
 * @param  {[type]} options.fuid       父分类id
 * @param  {[type]} options.goods_id   商品id
 * @return Promise
 */
export function getJoinList({ page_index, page_size,fuid, goods_id  })
{
	return $http.post('',{module:'Activity#shareJoinList',page_index, page_size,fuid, goods_id })
}